<template>
    <el-container style="width: 100%">
        <!-- <el-header>Header</el-header> -->
        <el-main style="width: 100%;height:100%">
            <!-- <div class="title">青海省中波中心台>调度令>列表</div> -->
            <stations v-if="ifstationChoose" ref="stationsComp" @sendStations="getStations" style="margin-bottom:40px;"></stations>

            <el-form label-width="80px" ref="editfrom" :rules="editrules" :model="fromData" label-position="left" status-icon>
                <el-row :gutter="20">
                    <el-col :span="4">

                        <el-form-item label="台站" prop="stationInput">
                            <el-input v-model="fromData.stationInput" disabled class="m-2" placeholder="" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="语言" prop="Language">
                            <el-select v-model="fromData.Language" class="m-2" placeholder="">
                                <el-option v-for="item in language" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="频率" prop="Frequency">
                            <el-select v-model="fromData.Frequency" class="m-2" placeholder="">
                                <el-option v-for="item in frequency" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="周期" prop="RepeatType">
                            <el-select v-model="fromData.RepeatType" class="m-2" @change="repeatTypechange" placeholder="">
                                <el-option v-for="item in repeatType" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="重复标记" prop="repeatarry">
                            <el-input v-model="fromData.repeatarry" class="m-2" placeholder="" :disabled="fromData.RepeatType==0" />
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="保障级别" prop="Priority">
                            <el-select v-model="fromData.Priority" class="m-2" placeholder="">
                                <el-option v-for="item in priority" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="4">

                        <el-form-item label="机号" prop="TransmitterNumber">
                            <el-select v-model="fromData.TransmitterNumber" class="m-2" placeholder="">
                                <el-option v-for="item in transmitterNumber" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="功率" prop="Capacity">
                            <el-select v-model="fromData.Capacity" class="m-2" placeholder="">
                                <el-option v-for="item in capacity" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label="天线">
                            <el-select v-model="fromData.AnntenaNumber" class="m-2" placeholder="">
                                <el-option v-for="item in anntenanumber" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="开始日期" prop="RepeatDateBegin">
                            <el-date-picker v-model="fromData.RepeatDateBegin" type="date" placeholder="开始日期" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="结束日期" prop="RepeatDateEnd">
                            <el-date-picker v-model="fromData.RepeatDateEnd" type="date" placeholder="开始日期" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="直属台" prop="Directly">
                            <el-select v-model="fromData.Directly" class="m-2" placeholder="">
                                <el-option v-for="item in directly" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>

                <el-row :gutter="20">
                    <el-col :span="4">

                        <el-form-item label="开始时间1" prop="StartTime1">
                            <el-time-picker v-model="fromData.StartTime1" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.StartTime1" class="m-2" placeholder="" filterable allow-create name='StartTime1' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="开始时间2">
                            <el-time-picker v-model="fromData.StartTime2" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.StartTime2" class="m-2" placeholder="" filterable allow-create name='StartTime2' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="开始时间3">
                            <el-time-picker v-model="fromData.StartTime3" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.StartTime3" class="m-2" placeholder="" filterable allow-create name='StartTime3' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="开始时间4">
                            <el-time-picker v-model="fromData.StartTime4" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.StartTime4" class="m-2" placeholder="" filterable allow-create name='StartTime4' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="开始时间5">
                            <el-time-picker v-model="fromData.StartTime5" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.StartTime5" class="m-2" placeholder="" filterable allow-create name='StartTime5' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>

                </el-row>

                <el-row :gutter="20">

                    <el-col :span="4">

                        <el-form-item label="结束时间1" prop="EndTime1">
                            <el-time-picker v-model="fromData.EndTime1" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.EndTime1" class="m-2" placeholder="" filterable allow-create name='EndTime1' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="结束时间2">
                            <el-time-picker v-model="fromData.EndTime2" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.EndTime2" class="m-2" placeholder="" filterable allow-create name='EndTime2' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">

                        <el-form-item label="结束时间3">
                            <el-time-picker v-model="fromData.EndTime3" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.EndTime3" class="m-2" placeholder="" filterable allow-create name='EndTime3' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="结束时间4">
                            <el-time-picker v-model="fromData.EndTime4" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.EndTime4" class="m-2" placeholder="" filterable allow-create name='EndTime4' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="结束时间5">
                            <el-time-picker v-model="fromData.EndTime5" class="m-2" placeholder="" />
                            <!-- <el-select v-model="fromData.EndTime5" class="m-2" placeholder="" filterable allow-create name='EndTime5' @blur="selectBlur">
                                <el-option v-for="item in time" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select> -->
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20">
                    <el-col :span="4">
                        <el-checkbox v-model="ifDisabled" size="large" />
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="4">

                        <el-form-item label="节目">
                            <el-select v-model="fromData.Program" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in program" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="通道">
                            <el-select v-model="fromData.ThoroughFare" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in thoroughfare" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="4">

                        <el-form-item label="天线">
                            <el-select v-model="fromData.AnntenaNumber" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in anntenanumber" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                    <el-col :span="4">

                        <el-form-item label="程式">
                            <el-select v-model="fromData.Form" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in form" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="业务">
                            <el-select v-model="fromData.Business" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in business" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-row :gutter="20">
                    <el-col :span="4">

                        <el-form-item label="方向">
                            <el-select v-model="fromData.Direction" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in direction" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="服务区">
                            <el-select v-model="fromData.Service" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in service" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="操作">
                            <el-select v-model="fromData.Oprate" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in oprate" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="其他">
                            <el-select v-model="fromData.Other" class="m-2" placeholder="" :disabled="!ifDisabled">
                                <el-option v-for="item in other" :key="item.value" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">

                        <el-form-item label="备注">
                            <el-input v-model="fromData.Remarks" class="m-2" placeholder="" :disabled="!ifDisabled" />
                        </el-form-item>
                    </el-col>

                </el-row>
            </el-form>

        </el-main>
        <el-footer class="elfooter">

            <el-button type="primary" size="small" @click="saveRow(0)">保存</el-button>
            <el-button type="primary" size="small" @click="saveRow(1)" icon="el-icon-plus">保存并新增</el-button>
            <el-button size="small" type="primary" plain @click="closeDialog">返回</el-button>
        </el-footer>
    </el-container>
</template>
  <script setup>  
import { reactive, getCurrentInstance, defineExpose, defineEmits, onMounted, ref, nextTick } from 'vue'
import stations from './components/stations.vue'
const { proxy } = getCurrentInstance()
const emit = defineEmits(['sendNewrow', 'closeDialog', 'fresh'])
// const props = defineProps({
//     stationsJson: Object
// })
// console.log(props.stationsJson);


//#region pram

//表单验证规则
let editrules = reactive({
    Language: [
        { required: true, message: '请选择语言', trigger: 'blur' }
    ],
    Frequency: [
        { required: true, message: '请选择频率', trigger: 'blur' }
    ],
    RepeatDateBegin: [
        { required: true, message: '请选择开始日期', trigger: 'blur' }
    ],
    RepeatDateEnd: [
        { required: true, message: '请选择结束日期', trigger: 'blur' }
    ],

})

//台站选择组件
let stationsComp = ref(null)
//表单组件
let editfrom = ref(null)
//表单数据
let fromData = reactive({
    Priority: 0,
    stationInput: '自动(默认)',
    StationIDs: '',
    Language: '英',
    Frequency: '',
    StartTime1: '',
    EndTime1: '',
    StartTime2: '',
    EndTime2: '',
    StartTime3: '',
    EndTime3: '',
    StartTime4: '',
    EndTime4: '',
    StartTime5: '',
    EndTime5: '',
    RepeatType: 0,
    repeatarry: '',
    RepeatWeek: '',
    RepeatMonth: '',
    RepeatDateList: '',
    RepeatDateBegin: '',
    RepeatDateEnd: '',
    Directly: 1,
    TransmitterNumber: '自动(默认)',
    Capacity: '自动(默认)',
    Program: '',
    ThoroughFare: 0,
    AnntenaNumber: '自动(默认)',
    Form: '',
    Business: '',
    Direction: 0,
    Service: '',
    Oprate: 1,
    Other: '',
    Remarks: ''
})

//语言
let language = reactive([
    {
        value: '英',
        label: '英',
    }
    ,
    {
        value: '中',
        label: '中',
    }
    ,
    {
        value: '法',
        label: '法',
    }
    ,
    {
        value: '德',
        label: '德',
    }
    ,
    {
        value: '日',
        label: '日',
    }
    ,
    {
        value: '韩',
        label: '韩',
    }
])
//频率
let frequency = reactive([
    {
        value: '9600',
        label: '9600',
    }
    ,
    {
        value: '9700',
        label: '9700',
    }
    ,
    {
        value: '9800',
        label: '9800',
    }
    ,
    {
        value: '9900',
        label: '9900',
    }
])
//时间
let time = reactive([
    {
        value: '00:00',
        label: '00:00',
    },
    {
        value: '01:00',
        label: '01:00',
    },
    {
        value: '02:00',
        label: '02:00',
    },
    {
        value: '03:00',
        label: '03:00',
    },
    {
        value: '04:00',
        label: '04:00',
    },
    {
        value: '05:00',
        label: '05:00',
    },
    {
        value: '06:00',
        label: '06:00',
    },
    {
        value: '07:00',
        label: '07:00',
    },
    {
        value: '08:00',
        label: '08:00',
    },
    {
        value: '09:00',
        label: '09:00',
    },
    {
        value: '10:00',
        label: '10:00',
    },
    {
        value: '11:00',
        label: '11:00',
    },
    {
        value: '12:00',
        label: '12:00',
    },
    {
        value: '13:00',
        label: '13:00',
    },
    {
        value: '14:00',
        label: '14:00',
    },
    {
        value: '15:00',
        label: '15:00',
    },
    {
        value: '16:00',
        label: '16:00',
    },
    {
        value: '17:00',
        label: '17:00',
    },
    {
        value: '18:00',
        label: '18:00',
    },
    {
        value: '19:00',
        label: '19:00',
    },
    {
        value: '20:00',
        label: '20:00',
    },
    {
        value: '21:00',
        label: '21:00',
    },
    {
        value: '22:00',
        label: '22:00',
    },
    {
        value: '23:00',
        label: '23:00',
    },
    {
        value: '24:00',
        label: '24:00',
    },
])
//周期
let repeatType = reactive([
    {
        value: 0,
        label: '每天',
    }
    ,
    {
        value: 1,
        label: '每周',
    }
    ,
    {
        value: 2,
        label: '每月',
    }
    ,
    {
        value: 3,
        label: '指定日期',
    }
])
//直属台
let directly = reactive([

    {
        value: 1,
        label: '是',
    }
    ,
    {
        value: 0,
        label: '否',
    }

])
//发射机
let transmitterNumber = reactive([
    {
        value: 1,
        label: 1,
    }
    ,
    {
        value: 2,
        label: 2,
    }
])
//功率
let capacity = reactive([
    {
        value: 150,
        label: 150,
    }
    ,
    {
        value: 120,
        label: 120,
    }
])
//节目
let program = reactive([
    {
        value: '英.中一',
        label: '英.中一',
    }
])
//通道
let thoroughfare = reactive([
    {
        value: 20,
        label: 20,
    }
])
//天线
let anntenanumber = reactive([
    {
        value: 1,
        label: 1,
    }
])
//程式
let form = reactive([
    {
        value: 'HR3/3/0.5',
        label: 'HR3/3/0.5',
    }
])
//业务
let business = reactive([
    {
        value: '对外广播',
        label: '对外广播',
    }
])
//方向
let direction = reactive([
    {
        value: 260,
        label: 260,
    }
])
//服务区
let service = reactive([
    {
        value: '大洋洲',
        label: '大洋洲',
    }
])
//操作
let oprate = reactive([
    {
        value: 0,
        label: '关',
    },
    {
        value: 1,
        label: '开',
    }
])
//其他
let other = reactive([
])
//保障级别
let priority = reactive([
    {
        value: 0,
        label: '无级别',
    },
    {
        value: 1,
        label: '一般',
    },
    {
        value: 2,
        label: '重要',
    },
    {
        value: 3,
        label: '优先',
    }
])
//台站选择
let stationChoose = ''
//最后两行选项是否可选
let ifDisabled = ref(false)
//选中行的index 未选择-1
let rowIndex = -1
//是否显示台站选择
let ifstationChoose = ref(true)

//#endregion

//#region method

//周期选择事件
let repeatTypechange = (value) => {

    if (value == 0)
        fromData.repeatarry = ''
}

//时间下拉框自定义输入
let selectBlur = (e) => {

    fromData[e.target.name] = e.target.value
}
//获取台站选择
let getStations = (labelstring, stationsjson, value) => {
    // if (proxy.$TOOL.data.get("USER_INFO").deptTtype == '台站') {
    //     fromData.stationInput = proxy.$TOOL.data.get("USER_INFO").deptLongName.substr(1).replace('/', '-')
    //     fromData.StationIDs = proxy.$TOOL.data.get("USER_INFO").deptId
    // }
    // else {
    fromData.stationInput = labelstring
    fromData.StationIDs = value
    //}

}
//台站初始化赋值
let setStationvalue = (jsonstring, stationIds, stationInput) => {
    nextTick(() => {

        if (stationsComp.value != null) {

            stationsComp.value.setStationvalue(jsonstring, stationIds, stationInput, false)
        }

    })
}
//页面赋值
let setPage = (data, index, stationInput) => {
    let _obj = JSON.stringify(data)
    let newobj = JSON.parse(_obj)
    Object.assign(fromData, newobj)


    if (fromData.TransmitterNumber == undefined) {
        fromData.TransmitterNumber = '自动(默认)'
    }
    else {
        if (fromData.TransmitterNumber.toString() == '0' || fromData.TransmitterNumber == '')
            fromData.TransmitterNumber = '自动(默认)'
    }
    if (fromData.AnntenaNumber == undefined)
        fromData.AnntenaNumber = '自动(默认)'
    else {
        if (fromData.AnntenaNumber.toString() == '0' || fromData.AnntenaNumber == '')
            fromData.AnntenaNumber = '自动(默认)'
    }
    if (fromData.Capacity == undefined)
        fromData.Capacity = '自动(默认)'
    else {
        if (fromData.Capacity.toString() == '0' || fromData.Capacity == '')
            fromData.Capacity = '自动(默认)'
    }

    if (proxy.$TOOL.data.get("USER_INFO").deptTtype == '台站' && newobj.activeStep >= 2) {
        ifstationChoose.value = false
    }
    else
        ifstationChoose.value = true


    if (index == -1) {
        //新增状态
        rowIndex = -1
        editfrom.value.resetFields()

        fromData.StartTime1 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.StartTime2 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.StartTime3 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.StartTime4 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.StartTime5 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.EndTime1 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.EndTime2 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.EndTime3 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.EndTime4 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.EndTime5 = new Date(2011, 1, 1, 0, 0, 0)
        fromData.stationInput = stationInput

        if (proxy.$TOOL.data.get("USER_INFO").deptTtype == '台站') {
            nextTick(() => {
                fromData.stationInput = proxy.$TOOL.data.get("USER_INFO").deptLongName.substr(1).replace('/', '-')
                fromData.StationIDs = proxy.$TOOL.data.get("USER_INFO").deptId
            })
        }
        else
            fromData.stationInput = stationInput
        if (fromData.startTime != undefined) {
            if (fromData.RepeatDateBegin == '') {
                fromData.RepeatDateBegin = fromData.startTime

            }
        }
        if (fromData.endTime != undefined) {
            if (fromData.RepeatDateEnd == '')
                fromData.RepeatDateEnd = fromData.endTime
        }
    }
    else {
        //编辑状态
        rowIndex = index

        for (var j = 1; j < 6; j++) {
            fromData["StartTime" + j] = new Date('2011-01-01 ' + fromData["StartTime" + j])
            fromData["EndTime" + j] = new Date('2011-01-01 ' + fromData["EndTime" + j])
        }


        if (newobj.activeStep >= 2) {
            nextTick(() => {
                fromData.stationInput = newobj.StationName
                fromData.StationIDs = newobj.StationID
            })
        }
        else {

            nextTick(() => {
                setTimeout(() => {
                    console.log(22, newobj.StationIDs);
                    stationsComp.value.setStationvalue(undefined, newobj.StationIDs, undefined, false)
                }, 1000);

            })
        }
    }

}
//保存记录
let saveRow = async (type) => {
    editfrom.value.validate(async (valid) => {
        if (valid) {
            fromData.RepeatWeek = ''
            fromData.RepeatMonth = ''
            fromData.RepeatDateList = ''
            if (fromData.RepeatType == 1)
                fromData.RepeatWeek = fromData.repeatarry
            else if (fromData.RepeatType == 2)
                fromData.RepeatMonth = fromData.repeatarry
            else if (fromData.RepeatType == 3)
                fromData.RepeatDateList = fromData.repeatarry
            fromData.RepeatDateBegin = proxy.$TOOL.dateFormat(fromData.RepeatDateBegin, 'yyyy-MM-dd hh:mm:ss')
            fromData.RepeatDateEnd = proxy.$TOOL.dateFormat(fromData.RepeatDateEnd, 'yyyy-MM-dd hh:mm:ss')

            let _obj = JSON.stringify(fromData)
            let newdata = JSON.parse(_obj)
            //时间格式转字符
            for (var j = 1; j < 6; j++) {
                newdata["StartTime" + j] = proxy.$TOOL.dateFormat(newdata["StartTime" + j], 'hh:mm:ss')
                newdata["EndTime" + j] = proxy.$TOOL.dateFormat(newdata["EndTime" + j], 'hh:mm:ss')
            }
            if (rowIndex != -1) {
                //修改保存入库

                let result = await proxy.$API.order.updateDetail.post(newdata)

                if (result.code == 200) {
                    emit('fresh')
                    //emit('sendNewrow', fromData, rowIndex)
                    proxy.$message.success("保存成功")

                }
                else
                    proxy.$alert(result.message, "异常", { type: 'error' })
            }
            else {
                //判断是否有ProjectID 有则直接入库
                // let _obj = JSON.stringify(fromData)
                // let newdata = JSON.parse(_obj)

                if (newdata.activeStep < 2)
                // emit('sendNewrow', fromData, rowIndex)
                {
                    if (newdata.ProjectID != undefined) {
                        if (newdata.ProjectID > 0) {

                            let result = await proxy.$API.order.addContent.post(newdata)

                            if (result.code == 200) {
                                fromData.ContentID = result.ContentID
                                emit('fresh')
                                proxy.$message.success("新增成功")
                            }
                            else
                                proxy.$alert(result.message, "异常", { type: 'error' })
                        } else
                            emit('sendNewrow', newdata, rowIndex)
                    }
                    else
                        emit('sendNewrow', newdata, rowIndex)
                }
                else {
                    if (newdata.ProjectID != undefined) {
                        if (newdata.ProjectID > 0) {

                            let result = await proxy.$API.order.addPlan.post(newdata)
                            if (result.code == 200) {
                                fromData.DataID = result.DataID
                                emit('fresh')
                                proxy.$message.success("新增成功")
                            }
                            else
                                proxy.$alert(result.message, "异常", { type: 'error' })
                        } else
                            emit('sendNewrow', newdata, rowIndex)
                    }
                    else
                        emit('sendNewrow', newdata, rowIndex)
                }
            }

            if (type == 0)
                emit('closeDialog')
            else {
                //新增状态
                rowIndex = -1
                let stationInput = fromData.stationInput
                editfrom.value.resetFields()
                fromData.senderValue = proxy.$TOOL.data.get("USER_INFO").userId
                fromData.StartTime1 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.StartTime2 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.StartTime3 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.StartTime4 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.StartTime5 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.EndTime1 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.EndTime2 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.EndTime3 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.EndTime4 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.EndTime5 = new Date(2011, 1, 1, 0, 0, 0)
                fromData.stationInput = stationInput

                if (proxy.$TOOL.data.get("USER_INFO").deptTtype == '台站') {
                    nextTick(() => {
                        fromData.stationInput = proxy.$TOOL.data.get("USER_INFO").deptLongName.substr(1).replace('/', '-')
                        fromData.StationIDs = proxy.$TOOL.data.get("USER_INFO").deptId
                    })
                }
                else
                    fromData.stationInput = stationInput
            }
        }
    })
}

//返回
let closeDialog = () => {
    emit('closeDialog')
}

//初始化
onMounted(async () => {
})
//#endregion


//暴露的方法函数
defineExpose({ setStationvalue, setPage })

</script>
<style lang="scss">
.el-row {
    // margin-bottom: 20px;
}
.title {
    color: green;
    padding: 10px;
}
.topcard {
    width: 100%;
}
.box-card {
    width: 100%;
}
.elspace {
    overflow-x: auto;
}
.elcard {
    width: 157px;
    height: 207px;
}
.elfooter {
    display: flex;
    justify-content: center;
}
.elcol {
    display: flex;
    align-items: center;
}
</style>